package com.example.usercenter.common;

import org.apache.poi.ss.formula.functions.T;

/**
 * 返回工具类
 *
 * @author REN
 */
public class ResultUtils {

    public static <T> BaseResponse<T> success(T data) {
        return new BaseResponse<>(0, data,"ok");
    }

    /**
     * 失败
     *
     * @param errorCode
     * @return
     */
    public static BaseResponse error(ErrorCode errorCode) {
        return new BaseResponse<>(errorCode);
    }

    public static BaseResponse error(int code, String msg,String description) {
        return new BaseResponse<>(code, msg,null, description);
    }

    public static BaseResponse error(ErrorCode errorCode, String msg,String description) {
        return new BaseResponse<>(errorCode.getCode(), msg,null, description);
    }

    public static BaseResponse error(ErrorCode errorCode, String description) {
        return new BaseResponse<>(errorCode.getCode(), errorCode.getMsg(), description);
    }
}
